#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

#define flr(x,l,r) for (int x = l; x <= r; ++ x)
#define frl(x,r,l) for (int x = r; x >= l; -- x)
#define LL long long 
#define szf sizeof
#define in(x) scanf("%d", &x)
#define out(x) printf("%d", x)
#define pn printf("\n")
#define con continue
#define bk break
#define vc vector 
#define pb push_back
#define sz size

using namespace std;

const int N = 5e4 + 10;

int n, m;
int w[N], q[N], f[N];

bool check(int lenth) {
    int hh = 0, tt = 0;
    flr (i, 1, n) {
        if (q[hh] < i - lenth - 1) hh ++ ;
        f[i] = f[q[hh]] + w[i];
        while (hh <= tt && f[q[tt]] >= f[i]) tt --;
        q[ ++ tt] = i;
    }
    
    
    flr (i, n - lenth, n)
        if (f[i] <= m) 
            return true;
    
    return false;
}

int main() {
	 in(n), in(m);
	 
	 flr (i, 1, n) in(w[i]);
	 
	 int l = 0, r = n;
	 while (l < r) {
	     int mid = l + r >> 1;
	     if (check(mid)) r = mid;
	     else l = mid + 1;
	 }
	 
	out(l), pn;
	 
	return 0;
}